import React, { Component } from 'react';
import style from "./evaluation.module.css"
import { RightOutlined ,LikeFilled} from '@ant-design/icons';
import {withRouter} from "react-router-dom"
import { Link } from 'react-router-dom'
import axios from "axios"

class evaluation extends Component {
    state={
        dianzan:false,
        zan:11,
        pinglunlist:[]
    }
    componentDidMount(){
        const headerJSON = {
            "Content-Type": "application/json;charset=UTF-8"
        };
        axios({
            url:"/pinglun/comment/getAll",
            method:"post",
            header:headerJSON,
            data:{
                bid:this.props.id
            }
        }).then(res=>{
            this.setState({
                pinglunlist:res.data,
            })
            console.log(res,"pinglun")
        })
    }
    render() {
        let id = this.props.id
        console.log(id,"idididididid")
        return (
            <div className={style.evaluation}>
                <div className={style.evaluationTil}>
                    <span>楼盘评论</span>
                    <span className={style.all}>查看全部<RightOutlined style={{color:"#9a9a9a"}}/></span>
                </div>
                <div className={style.allEvaluation}>
                    全部
                </div>
                {this.state.pinglunlist.map(item=><div className={style.evaluationBox} key={item.id}>
                    <div className={style.userImg}>
                        {/* <img src=""></img> */}
                        头像
                    </div>
                    <div className={style.userCon}>
                        <p>{item.phone}</p>
                        <p className={style.content}>{item.content}</p>
                        <div className={style.bottom}>
                            <p>{item.time}</p>
                            <p>
                                {!this.state.dianzan&&<LikeFilled  onClick={(e)=>{
                                    this.state.zan+=1
                                    this.state.dianzan=!this.state.dianzan
                                    e.stopPropagation()
                                    this.setState({})
                                }}/>}
                                {this.state.dianzan&&<LikeFilled  className={style.zan} onClick={(e)=>{
                                    this.state.zan-=1
                                    this.state.dianzan=!this.state.dianzan
                                    e.stopPropagation()
                                    this.setState({})
                                }}/>}

                                {this.state.zan}
                            </p>
                        </div>
                    </div>
                </div>)}

                <Link key={id+200} to={{pathname:'/pinglun',state:{id:id}}}>
                <div className={style.review}>
                    我要点评
                </div></Link>
            </div>
        );
    }
}

export default evaluation;